1. Field of the Invention
The present invention relates to a communication device using three-step communication buffers and a data transmitting/receiving device, and more particularly, to a communication device using three-step communication buffers in which a serial communication device and a central processing unit can be always accessible to the three-step communication buffers.
2. Description of the Background Art
Generally, a large-scale integration circuit chip for communication and a circuit board for communication used in a serial communication terminal apparatus have a serial communication device (e.g. universal asynchronous receiver/transmitter, abbreviated UART) and a communication buffer for temporarily storing data therein. At this time, the communication buffer is provided to be accessible from two peripheral devices. The peripheral devices includes a serial communication device for transmitting and receiving data to/from an external device through a communication line, and a central processing unit for receiving data from the serial communication device or processing data to be transmitted through the serial communication device.
The transmitting/receiving device and the central processing unit use a communication buffer asynchronously, thereby accessing to the communication buffer at the same time. However, there is a disadvantage that incomplete data are accessed to cause an error to read and write unintended data.
The errors will be explained as follows in detail.
FIGS. 1A and 1B are diagrams showing problems of the communication device using one communication buffer according to a related art, in which FIG. 1A shows a case that synchronization of data is broken and FIG. 1B shows a case that incomplete data reading is generated.
FIG. 1A shows a case that the serial communication device 100 and the central processing unit 200 write data in one communication buffer 300. At this time, the writing and the reading have a special direction. That is, the central processing unit 200 stores data from an upper layer of the communication buffer 300 to a lower layer, and the serial communication device 100 sequentially reads the data from the upper layer of the communication buffer 300 to the lower layer and thereby transmitting the data to an external device (not shown).
However, in this process, in case that the serial communication device 100 reads data to be transmitted in a state that the central processing unit 200 does not complete to write the data or the central processing unit 200 reads data previously stored in the communication buffer 30 before the serial communication device 100 stores newly received data in the communication buffer 300 by a processing speed difference resulted from asynchronization of the central processing unit 200 and the serial communication device 100, data are not updated, that is, data do not have synchronism.
FIG. 1B shows a case that the same storage region of the communication buffer 300 is simultaneously accessed by the serial communication device 100 and the central processing unit 200. Herein, when the serial communication device 100 and the central processing unit 200 access to the same storage region of the communication buffer 300 at the same time, the data can be read incompletely.
Accordingly to this, in order to solve problems generated when one communication buffer is used, three-step communication buffers are used.
A communication device using three-step communication buffers according to the prior art and a method for transmitting/receiving data will be explained in detail with reference to attached drawings.
FIG. 2 is a construction view showing three-step communication buffers according to the prior art.
As shown in FIG. 2, the communication device comprises: a serial communication device 100 for transmitting/receiving data with an external device (not shown) in serial; a central processing unit 200 for processing data of an external device by accessing thereto or processing data of an inner device; three-step communication buffers BUF1, BUF2, and BUF3 respectively designated by DOUT1_BUF_PTR, DOUT2_BUF_PTR, and DOUT3_BUF_PTR for temporarily storing the data; an interrupt generator 500 for generating interrupt to the central processing unit 200; and a state buffer 400 for transmitting states of the respective communication buffers BUF1, BUF2, and BUF3 to the central processing unit 200.
A communication device using the three-step communication buffers according to the prior art and a method for transmitting/receiving data will be explained as follows.
Each of communication buffers BUF1, BUF2, and BUF3 is set to have any one state of xe2x80x9creadingxe2x80x9d, xe2x80x9cwritingxe2x80x9d, xe2x80x9cwaitingxe2x80x9d, and xe2x80x9cnot usingxe2x80x9d. The setting is stored in the state buffer 400. Then, the communication device designates the respective communication buffers BUF1, BUF2, and BUF3 with the pointers DOUT1_BUF_PTR, DOUT2_BUF_PTR, and DOUT3_BUF_PTR by using state information stored in the state buffer 400, thereby enabling to read and write.
According to this, a processing speed difference between the serial communication device 100 and the central processing unit 200 and an overlap of the processing location are not generated, thereby enabling to access to the respective communication buffers at all times.
Hereinafter, the communication device using the three-step communication buffers according to the related art and the method for transmitting/receiving data will be explained in detail.
1) A Method for Receiving Data
The serial communication device 100 selects one communication buffer BUF 1 to make into a data writing state. The communication buffer BUF1 is selected as an example, and the other communication buffers BUF 2 and BUF 3 can be also selected. The communication buffer BUF1 is designated and then received data are written in the communication buffer BUF 1.
Subsequently, when the reception of the data is completed, the serial communication device 100 changes a state of the communication buffer BUF 1 into that of a communication buffer where recent data are stored. This state information is stored in the state buffer 400.
Then, when the reception of the data is completed, the serial communication device 100 generates an interrupt to inform to the interrupt generator 500 that. The interrupt generator 500 applies the interrupt signal to the central processing unit 200. Then, the central processing unit 200 checks the state buffer 400, thereby checking in which communication buffer the recent data are stored.
If the central processing unit 200 checks the state buffer 400, the communication buffer BUF 1 where the recent data are stored is converted into a reading state. Then, the central processing unit 200 accesses to the communication buffer BUF 1 converted into the reading state to read the stored data.
Like this, since at least one communication buffer among the three communication buffers BUF1, BUF 2, and BUF 3 is not used in a process for receiving data or stores the recent data, the central processing unit 200 can access to the data at all times and an interference is not generated between the central processing unit 200 and the serial communication device 100.
2) A Method for Transmitting Data
Contrary to said receiving method, the central processing unit 200 checks a readable communication buffer by the state buffer 400, stores transmission data in the readable communication buffer BUF 3, and converts state information of the communication buffer BUF 3 into a state that data to be transmitted are stored. Then, the serial communication device 100 receives a request to transmit data from the external device, designates a state of the communication buffer BUF 3 where the data are stored into a readable state, and reads the data from the buffer BUF 3, thereby transmitting to the external device.
Like this, the communication device using the three communication buffers according to the related art can perform a stable data processing since an operation between the central processing unit 200 and the serial communication device 100 is not overlapped or interfered.
However, actually, the central processing unit 200 always reads the state buffer 400 at the time when the interference is generated or transmission data are written to check state information of the respective communication buffers, to find a communication buffer having the corresponding state, and to perform data reading or data writing, thereby having a complicated operation and a delayed time.
Therefore, an object of the present invention is to provide a communication device using three-step communication buffers which can prevent an error resulted from that a central processing unit and a serial communication device simultaneously access to three-step communication buffers at the time of reading and writing data.
Another object of the present invention is to provide a communication device using three-step communication buffers, in which a central processing unit and a serial communication device can access to each other without interference and time is not delayed by omitting to check a state of each communication buffer.
To achieve these and other advantages and in accordance with the purpose of the present invention, as embodied and broadly described herein, there is provided a communication device using three-step communication buffers comprising: a serial communication device for receiving data from another communication device or transmitting data to said another communication device; a central processing unit for reading data received from the serial communication device to process or providing the serial communication device with data to be transmitted to another communication device; an interrupt generator for generating an interrupt signal and outputting to the central processing unit when the serial communication device completes to receive the data; a system clock generator for generating a clock signal for synchronizing the communication device; a first communication buffer connected to the serial communication device for temporarily storing data received from the serial communication device or temporarily storing data to be transmitted to said another communication device from the central processing unit and for providing to the serial communication device; a third communication buffer enabled at a rising edge or a falling edge of the clock signal from the system clock generator for receiving data to temporarily store or outputting the stored data; and a second communication buffer connected between the first communication buffer and the third communication buffer and enabled at a different edge from the edge of the clock signal from the system clock generator which enables the third communication buffer for receiving data from the first communication buffer to temporarily store or outputting the stored data to the first communication buffer.
The foregoing and other objects, features, aspects and advantages of the present invention will become more apparent from the following detailed description of the present invention when taken in conjunction with the accompanying drawings.